<template>
	<div class="app">
		<h1 style="text-align: center;"> 录入成绩</h1>
		<!-- 年级 -->
		<el-card class="box-card">
			<template #header>
				<div class="card-header">
					<span>请选择年级</span>
				</div>
			</template>
			<el-select v-model="data.year" class="m-2" placeholder="Select" size="large">
				<el-option v-for="item in year" :key="item.value" :label="item.label" :value="item.value"/>
			</el-select>
		</el-card>
		<!-- 学业成绩-只针对研二 -->
		<el-card class="box-card" v-if="data.year == '2'">
			<template #header>
				<div class="card-header">
					<span>学业成绩</span>
				</div>
			</template>
			<el-input-number v-model="data.xueyeScore" :min="0" :max="20"/>
		</el-card>
		<!-- 思政表现 -->
		<el-card class="box-card">
			<template #header>
				<div class="card-header">
					<span>思政表现</span>
				</div>
			</template>
			<div style="display: flex;justify-content: space-between;">
				<div style="margin-right: 20px;">
					<p>思政类奖项获取情况</p>
					<el-radio-group v-model="data.sizheng.rongyuScore">
						<el-radio :label="0">无</el-radio>
						<el-radio :label="2">校级</el-radio>
						<el-radio :label="3">市级</el-radio>
						<el-radio :label="5">省级</el-radio>
					</el-radio-group>
				</div>
				<div style="margin-right: 20px;">
					<p>导师组评价</p>
					<el-radio-group v-model="data.sizheng.daoshiScore">
						<el-radio :label="4">良好</el-radio>
						<el-radio :label="5">优秀</el-radio>
					</el-radio-group>
				</div>
				<div>
					<p>扣分情况</p>
					<el-radio-group v-model="data.sizheng.koufengScore">
						<el-radio :label="0">无</el-radio>
						<el-radio :label="5">受到通报批评
							<el-input style="width: 100px;" v-model="data.sizheng.koufengTongBaoNum">
								<template #append>次</template>
							</el-input>
						</el-radio>
					</el-radio-group>
				</div>
			</div>
		</el-card>
		<!-- 科研能力 -->
		<el-card class="box-card">
			<template #header>
				<div class="card-header">
					<span>科研能力</span>
				</div>
			</template>
			<p>学术论文</p>
			<el-button type="success" @click="handleAdd()">新增</el-button>
			<el-button type="success" @click="submit()">保存</el-button>
			<el-table :data="data.luwenForm.tableData" style="width: 100%">
				<el-table-column v-for="(item, index) in data.luwenForm.tableHeader" :prop="item.keys" :label="item.label"
												 :key="index">
					<template #default="scope">
                        <span v-if="scope.row.isSet">
                            <el-form-item :prop="'tableData.' + scope.$index + '.' + item.keys">

                                <el-select v-if="item.keys == 'level'" v-model="scope.row[item.keys]" class="m-2"
																					 placeholder="请选择" size="large">
                                    <el-option v-for="item in xueshulunwen" :key="item.value" :label="item.label"
																							 :value="item.value"/>
                                </el-select>
                                <el-upload v-else-if="item.keys == 'file'" class="upload-demo"
																					 action="http://localhost:8989/business/file/upload"
																					 :on-preview="handlePreview"
																					 :on-success="onSuccess" :on-remove="handleRemove"
																					 :before-remove="beforeRemove" multiple
																					 :limit="1" :on-exceed="handleExceed"
																					 v-model:file-list="scope.row[item.keys]">
                                    <el-button size="small" type="primary">点击上传</el-button>
                                </el-upload>


                                <el-input disabled v-else-if="item.keys == 'score'" placeholder="分数无需填写-自动填充"
																					v-model="scope.row[item.keys]"></el-input>
                                <el-input v-else v-model="scope.row[item.keys]"></el-input>
                            </el-form-item>
                        </span>
						<span v-else>
                            <el-select v-if="item.keys == 'level'" disabled v-model="scope.row[item.keys]" class="m-2"
																			 placeholder="Select" size="large">
                                <el-option v-for="item in xueshulunwen" :key="item.value" :label="item.label"
																					 :value="item.value"/>
                            </el-select>
                            <span v-else-if="item.keys == 'score'">
                                {{ scope.row['level'] }}
                            </span>
                            <el-button v-else-if="item.keys == 'file'"
																			 @click="yulan(scope.row[item.keys])">预览</el-button>
                            <span v-else>
                                {{ scope.row[item.keys] }}
                            </span>


                        </span>
					</template>
				</el-table-column>
				<el-table-column label="操作">
					<template #default="scope">
						<el-button v-if="!scope.row.isSet" type="primary" @click="handleEdit(scope.$index, scope.row)">
							编辑
						</el-button>
						<el-button type="danger" @click="handleDelete(scope.$index, scope.row)">
							删除
						</el-button>
					</template>
				</el-table-column>

			</el-table>


			<p>知识产权</p>
			<el-checkbox-group class="zhishichanquan" v-model="data.zhishichanquan.zhishichanquanScore">

				<el-checkbox label="a-5">发明专利获发明专利授权，取得证书
					<el-input class="w-50 m-2" v-model="data.zhishichanquan.a">
						<template #append>项</template>
					</el-input>
				</el-checkbox>
				<el-checkbox label="b-3">发明专利进入实质审查阶段
					<el-input class="w-50 m-2" v-model="data.zhishichanquan.b">
						<template #append>项</template>
					</el-input>
				</el-checkbox>
				<el-checkbox label="c-2">实用新型专利授权或在公开期内
					<el-input class="w-50 m-2" v-model="data.zhishichanquan.c">
						<template #append>项</template>
					</el-input>
				</el-checkbox>
				<el-checkbox label="d-1">获软件著作权证书
					<el-input class="w-50 m-2" v-model="data.zhishichanquan.d">
						<template #append>项</template>
					</el-input>
				</el-checkbox>

			</el-checkbox-group>
			<p>科研项目</p>
			<el-checkbox-group class="zhishichanquan" v-model="data.keyanxiangmu.keyanxiangmuScore">

				<el-checkbox label="a-5">研究生创新项目
					<el-input class="w-50 m-2" v-model="data.keyanxiangmu.a">
						<template #append>项</template>
					</el-input>
				</el-checkbox>
				<el-checkbox label="b-3">导师组横纵向科研项目
					<el-input class="w-50 m-2" v-model="data.keyanxiangmu.b">
						<template #append>项</template>
					</el-input>
				</el-checkbox>
				<el-checkbox label="c-2">实用新型专利授权或在公开期内
					<el-input class="w-50 m-2" v-model="data.keyanxiangmu.c">
						<template #append>项</template>
					</el-input>
				</el-checkbox>
				<el-checkbox label="d-1">获软件著作权证书
					<el-input class="w-50 m-2" v-model="data.keyanxiangmu.d">
						<template #append>项</template>
					</el-input>
				</el-checkbox>
			</el-checkbox-group>

			<p>学科竞赛</p>
			<!-- <span>级别</span> -->
			<el-button type="success" @click="handleJingSaiAdd()">新增</el-button>
			<el-button type="success" @click="JingSaisubmit()">保存</el-button>
			<el-table :data="data.jingsaiForm.tableData" style="width: 100%">
				<el-table-column v-for="(item, index) in data.jingsaiForm.tableHeader" :prop="item.keys" :label="item.label"
												 :key="index">
					<template #default="scope">
                        <span v-if="scope.row.isSet">
                            <el-form-item :prop="'tableData.' + scope.$index + '.' + item.keys">


                                <el-select v-if="item.keys == 'level'" v-model="scope.row[item.keys]" class="m-2"
																					 placeholder="请选择获奖级别" size="large">
                                    <el-option v-for="item in jibie" :key="item.value" :label="item.label"
																							 :value="item.value"/>
                                </el-select>
                                <el-upload v-else-if="item.keys == 'file'" class="upload-demo"
																					 action="http://localhost:8989/business/file/upload"
																					 :on-preview="handlePreview"
																					 :on-success="onSuccess" :on-remove="handleRemove"
																					 :before-remove="beforeRemove" multiple
																					 :limit="1" :on-exceed="handleExceed"
																					 v-model:file-list="scope.row[item.keys]">
                                    <el-button size="small" type="primary">点击上传</el-button>
                                </el-upload>


                                <el-input disabled v-else-if="item.keys == 'score'" placeholder="分数无需填写-自动填充"
																					v-model="scope.row[item.keys]"></el-input>
                                <el-input v-else v-model="scope.row[item.keys]"></el-input>
                            </el-form-item>
                        </span>
						<span v-else>
                            <el-select v-if="item.keys == 'level'" disabled v-model="scope.row[item.keys]" class="m-2"
																			 placeholder="Select" size="large">
                                <el-option v-for="item in jibie" :key="item.value" :label="item.label"
																					 :value="item.value"/>
                            </el-select>

                            <span v-else-if="item.keys == 'score'">
                                {{ scope.row['level'] }}
                            </span>
                            <el-button v-else-if="item.keys == 'file'"
																			 @click="yulan(scope.row[item.keys])">预览</el-button>

                            <span v-else>
                                {{ scope.row[item.keys] }}
                            </span>


                        </span>
					</template>
				</el-table-column>
				<el-table-column label="操作">
					<template #default="scope">
						<el-button v-if="!scope.row.isSet" type="primary"
											 @click="handleJingsaiEdit(scope.$index, scope.row)">
							编辑
						</el-button>
						<el-button type="danger" @click="handleJingsaiDelete(scope.$index, scope.row)">
							删除
						</el-button>
					</template>
				</el-table-column>

			</el-table>
			<!-- <el-select v-model="data.jibieScore" class="m-2" placeholder="Select" size="large">
					<el-option v-for="item in jibie" :key="item.value" :label="item.label" :value="item.value" />
			</el-select> -->
		</el-card>
		<!-- 社会服务 -->
		<el-card class="box-card">
			<template #header>
				<div class="card-header">
					<span>社会服务</span>
				</div>
			</template>
			<div style="display: flex;justify-content: space-around;">
				<div>
					<p>所获荣誉</p>
					<el-select v-model="data.shehuifuwuScore" class="m-2 w-200" placeholder="Select" size="large">
						<el-option v-for="item in shehuifuwu" :key="item.value" :label="item.label" :value="item.value"/>
					</el-select>
				</div>
				<div>
					<p>扣分情况</p>
					<el-radio-group v-model="data.shehuifuwu.koufenType">
						<el-radio :label="0">无</el-radio>
						<el-radio :label="5">校、院组织的各项集体活动，未经批准而缺勤
							<el-input style="width: 100px;" v-model="data.shehuifuwu.koufengNum">
								<template #append>次</template>
							</el-input>
						</el-radio>
					</el-radio-group>
				</div>
			</div>

		</el-card>
		<el-button @click="save" type="success">保存</el-button>

	</div>
</template>
<script>
import {handlerScore, getInfoStudent} from "@/api/app/student";

export default {
	name: "Student",
	data() {
		return {
			data: {

				luwenForm: {
					tableHeader: [
						{
							label: "论文名称",
							keys: "lw_name",
						},
						{
							label: "发表杂志名称",
							keys: "zz_name",
						},
						{
							label: "论文级别",
							keys: "level",
						},
						{
							label: "附件",
							keys: "file",
						},
						{
							label: "分数",
							keys: "score",
						},
					],
					tableData: [],
				},
				jingsaiForm: {
					tableHeader: [
						{
							label: "竞赛名称",
							keys: "js_name",
						},

						{
							label: "获奖级别",
							keys: "level",
						},
						{
							label: "附件",
							keys: "file",
						},
						{
							label: "分数",
							keys: "score",
						},
					],
					tableData: [],
				},
				year: '2',
				xueyeScore: 20,
				sizheng: {
					daoshiScore: 4,
					rongyuScore: 0,
					koufengScore: 0,
					koufengTongBaoNum: 0,
				},
				xueshulunwenScore: '0',
				zhishichanquan: {
					zhishichanquanScore: [],
					a: 0,
					b: 0,
					c: 0,
					d: 0

				},
				keyanxiangmu: {
					keyanxiangmuScore: [],
					a: 0,
					b: 0,
					c: 0,
					d: 0
				},
				shehuifuwu: {
					koufenType: 0,
					koufengNum: 0,
				},
				jibieScore: '0',
				shehuifuwuScore: '0',
				shehuifuwukoufengScore: 0

			},


			shehuifuwu: [
				{
					label: "担任校研究生会主席团成员、担任兼职辅导员",
					value: "3",
				},
				{
					label: "部门负责人、担任党务工作者、就业工作助手、代理班长、学生工作助理、助管、助教、担任班级班长、团支书",
					value: "2",
				},
				{
					label: "部门成员、助研、其他班委",
					value: "1",
				},
				{
					label: "参加经学院认定的大型活动，如：方阵检阅、团体表演、大型晚会等",
					value: "0.8",
				},
				{
					label: "参加经学院认定的校、院级一般活动并获得相关奖项|参与服务民族地区和地方经济发展的考察和实践活动，及各类志愿服务活动",
					value: "0.2",
				},
				{
					label: "组织和筹备经学院认定的学术会议和大型活动，担任工作人员",
					value: "0.5",
				},
				{
					label: "无",
					value: "0",
				}
			],
			jibie: [
				// A1
				{
					label: "国家级-A1-一等奖",
					value: "国家级-A1-30",
				},
				{
					label: "国家级-A1-二等奖",
					value: "国家级-A1-25",
				},
				{
					label: "国家级-A1-三等奖",
					value: "国家级-A1-20",
				},
				// A2
				{
					label: "国家级-A2-一等奖",
					value: "国家级-A2-20",
				},
				{
					label: "国家级-A2-二等奖",
					value: "国家级-A2-16",
				},
				{
					label: "国家级-A2-三等奖",
					value: "国家级-A2-12",
				},
				// A3
				{
					label: "国家级-A3-一等奖",
					value: "国家级-A3-15",
				},
				{
					label: "国家级-A3-二等奖",
					value: "国家级-A3-12",
				},
				{
					label: "国家级-A3-三等奖",
					value: "国家级-A3-9",
				},
				// 省级
				// A1
				{
					label: "省级-A1-一等奖",
					value: "省级-A1-15",
				},
				{
					label: "省级-A1-二等奖",
					value: "省级-A1-12",
				},
				{
					label: "省级-A1-三等奖",
					value: "省级-A1-9",
				},
				// A2
				{
					label: "省级-A2-一等奖",
					value: "省级-A2-10",
				},
				{
					label: "省级-A2-二等奖",
					value: "省级-A2-8",
				},
				{
					label: "省级-A2-三等奖",
					value: "省级-A2-6",
				},
				// A3
				{
					label: "省级-A3-一等奖",
					value: "省级-A3-8",
				},
				{
					label: "省级-A3-二等奖",
					value: "省级-A3-6",
				},
				{
					label: "省级-A3-三等奖",
					value: "省级-A3-4",
				},
				// 市级
				// A1
				{
					label: "市级-A1-一等奖",
					value: "市级-A1-4",
				},
				{
					label: "市级-A1-二等奖",
					value: "市级-A1-3.5",
				},
				{
					label: "市级-A1-三等奖",
					value: "市级-A1-3",
				},
				// A2
				{
					label: "市级-A2-一等奖",
					value: "市级-A2-3.5",
				},
				{
					label: "市级-A2-二等奖",
					value: "市级-A2-3",
				},
				{
					label: "市级-A2-三等奖",
					value: "市级-A2-2.5",
				},
				// A3
				{
					label: "市级-A3-一等奖",
					value: "市级-A3-3",
				},
				{
					label: "市级-A3-二等奖",
					value: "市级-A3-2.5",
				},
				{
					label: "市级-A3-三等奖",
					value: "市级-A3-2",
				},
				{
					label: "校级（创新学院认定）-一等奖",
					value: "校级（创新学院认定）-1.5"
				},
				{
					label: "校级（创新学院认定）-二等奖",
					value: "校级（创新学院认定）-1"
				},
				{
					label: "校级（创新学院认定）-三等奖",
					value: "校级（创新学院认定）-0.5"
				},

				{
					label: "非学校认定的 CCF 举办正式比赛和评测",
					value: "0.2"
				},
				{
					label: "无",
					value: "0"
				},
			],

			xueshulunwen: [
				{
					label: "CCF推荐A类国际学术期刊/中科院1区",
					value: "30",
				},
				{
					label: "CCF推荐B类国际学术期刊和A类国际学术会议/CCF高质量中文期刊T1类/中科院2区",
					value: "25",
				},
				{
					label: "CCF推荐的C类国际学术期刊和B类国际学术会议/中科院3区",
					value: "20",
				},
				{
					label: "CCF推荐C类国际会议/CCF高质量中文期刊T2类/中科院4区/EI期刊",
					value: "15",
				},
				{
					label: "CCF高质量中文期刊T3类/北大中文核心/CSCD中文核心",
					value: "10",
				},
				{
					label: "一般学术期刊/国内外学术会议",
					value: "5",
				},
				{
					label: "无",
					value: "0",
				}
			],
			year: [
				// {
				//     label:"研一年级",
				//     value:"1",
				// },
				{
					label: "研二年级",
					value: "2",
				},
				{
					label: "研三年级",
					value: "3",
				}
			],
			// 遮罩层
			loading: true,
			// 选中数组
			ids: [],
			// 非单个禁用
			single: true,
			// 非多个禁用
			multiple: true,
			// 显示搜索条件
			showSearch: true,
			// 总条数
			total: 0,
			// 学生表格数据
			studentList: [],
			// 弹出层标题
			title: "",
			// 是否显示弹出层
			open: false,
			// 查询参数
			queryParams: {
				pageNum: 1,
				pageSize: 10,
				name: null,
				sno: null,
				grade: null,
				infoId: null,
				score: null
			},
			// 表单参数
			form: {},
			// 表单校验
			rules: {},
			ddd: []
		};
	},
	created() {
		// console.log('tableHeader2', this.data);
		this.getStudentInfo();
		// console.log(JSON.parse(this.$route.query.data).id);
	},
	mounted() {

		// console.log('tableHeader2', this.data);
	},
	methods: {

		// 预览
		yulan(row) {
			console.log(row[0].response.url);
			var url = 'http://localhost:8989/business/file/lookFile?fileId=' + row[0].response.url

			window.open(url, '_blank');

		},
		onSuccess(response, uploadFile) {
			console.log('response', response);

		},
		handleRemove(file, fileList) {
			console.log(file, fileList);
		},
		handlePreview(file) {
			console.log(file);
		},
		handleExceed(files, fileList) {
			this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
		},
		beforeRemove(file, fileList) {

		},
		//竞赛提交
		JingSaisubmit() {
			this.data.jingsaiForm.tableData.forEach((item, index) => {
				item.isSet = false;
			});
			console.log('this.jingsaiForm.tableData', this.data.jingsaiForm.tableData);
			this.$set(this.data.jingsaiForm.tableData);
		},
		//竞赛新增
		handleJingSaiAdd() {
			let row = {};
			this.data.jingsaiForm.tableHeader.forEach((item, index) => {
				row.isSet = true;
			});
			this.data.jingsaiForm.tableData.push(row);
		},
		//竞赛编辑
		handleJingsaiEdit(index, row) {
			row.isSet = true;
			this.$set(this.data.jingsaiForm.tableData, index, row);
		},
		//论文删除
		handleJingsaiDelete(index, row) {
			this.data.jingsaiForm.tableData.splice(index, 1);
		},

		//论文提交
		submit() {
			this.data.luwenForm.tableData.forEach((item, index) => {
				item.isSet = false;
			});
			console.log('this.data.luwenForm.tableData', this.data.luwenForm.tableData);
			this.$set(this.data.luwenForm.tableData);
		},
		//论文新增
		handleAdd() {
			let row = {};
			this.data.luwenForm.tableHeader.forEach((item, index) => {
				row.isSet = true;
			});
			this.data.luwenForm.tableData.push(row);
		},
		//论文编辑
		handleEdit(index, row) {
			row.isSet = true;
			this.$set(this.data.luwenForm.tableData, index, row);
		},
		//论文删除
		handleDelete(index, row) {
			this.data.luwenForm.tableData.splice(index, 1);
		},

		async save() {

			const res = await handlerScore({
				data: JSON.stringify(this.data),

				id: JSON.parse(this.$route.query.data).id
			});
			ElMessage({
				message: '保存成功',
				type: 'success',
			})

			console.log(res);
		},
		async getStudentInfo() {
			const res = await getInfoStudent(JSON.parse(this.$route.query.data).id);
			if (res.code == 200) {
				this.data = JSON.parse(res.data.info)
			}


			console.log('学生录入成绩Info', res)
		}
	}
};
</script>
<style scoped>
.app {
	padding: 20px;
}

.box-card {
	margin-bottom: 10px;
}

.zhishichanquan {
	align-items: flex-start;
	display: flex;
	flex-direction: column;
}
</style>
